﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Security.Cryptography;


public partial class Template : System.Web.UI.MasterPage
{
    
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request.Cookies["CookieName"] != null)
            {
                pnDangNhap.Visible = false;
                pnThongTinCaNhan.Visible = true;
                hlhello.Text = "Xin chào , " + Session["tendn"].ToString();
            }
            else
            {
                pnDangNhap.Visible = true;
                pnThongTinCaNhan.Visible = false;
            }
        }
    }
    protected void btnDangNhap_Click(object sender, EventArgs e)
    {
        if (System.Web.Security.FormsAuthentication.Authenticate(txtTenDangNhap.Text, txtMatKhau.Text) == true)
        {
            System.Web.Security.FormsAuthentication.RedirectFromLoginPage(txtTenDangNhap.Text, false);
            Session["tendn"] = txtTenDangNhap.Text;
            Response.Redirect(Request.Url.AbsoluteUri.ToString());
        }
        else
        {
            lbThongbao.Text = "Đăng nhập thất bại";
        }
    }
}
